package com.tdam2013.grupo07.fragments;

import com.tdam2013.grupo07.R;

import android.app.ActionBar.Tab;
import android.app.ActionBar.TabListener;
import android.app.Fragment;
import android.app.FragmentTransaction;

public class FragmentTabListener implements TabListener{

	private final Fragment fragment;
	private boolean added=false;
	
	public FragmentTabListener(Fragment fragment)
	{
		this.fragment=fragment;
		
	}
	@Override
	public void onTabReselected(Tab tab, FragmentTransaction ft) {
		// TODO Auto-generated method stub
	}

	@Override
	public void onTabSelected(Tab tab, FragmentTransaction ft) {
		if(!added)
		{
			ft.add(android.R.id.content, fragment);
			added=true;
		}
		else
			ft.replace(android.R.id.content, fragment);		
			
	}

	@Override
	public void onTabUnselected(Tab tab, FragmentTransaction ft) {
        ft.remove(fragment);
	}

}
